﻿using System;
using System.ComponentModel.DataAnnotations;
using Ornament.Domain;

namespace Products.Databases
{
    [Serializable]
    public class TableSnapshot : DomainObject<Guid>, ISnapShot
    {
        private string _name;

        protected TableSnapshot()
        {
        }

        internal TableSnapshot(ProductVersion productVersion, ActionType actionType)
        {
            Version = productVersion;
            State = actionType;
        }

        #region ISnapShot Members

        [Required, Display(Name = "Table Name")]
        public virtual string Name
        {
            get { return _name; }
            set { _name = value.Trim(); }
        }

        public virtual string Memo { get; set; }
        public virtual ProductVersion Version { get; set; }
        public virtual ActionType State { get; private set; }

        public virtual string StateMemo { get; set; }

        #endregion

        protected override int CreateHashCode()
        {
            return Id.GetHashCode();
        }
    }
}